package org.trafficman.trafficman_sample_test;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Vector;

import org.punit.type.Concurrent;

public class ListTestClass implements Concurrent {

    private static final int LIST_COUNT = 10000;
    private static Object element = new Object();
    private Random indexGenerator = new Random();

    public void testInsertArrayList() {
        ArrayList<Object> arrayList = new ArrayList<Object>(LIST_COUNT);
        insertSequence(arrayList);
        insertRandom(arrayList);
    }

    public void testInsertVector() {
        Vector<Object> vector = new Vector<Object>(LIST_COUNT);
        insertSequence(vector);
        insertRandom(vector);
    }

    public void insertSequence(List<Object> list) {
        for (int i = 0; i < LIST_COUNT; ++i) {
            list.add(element);
        }
    }

    public void insertRandom(List<Object> list) {
        for (int i = 0; i < LIST_COUNT; ++i) {
            list.add(indexGenerator.nextInt(LIST_COUNT), element);
        }
    }

    public int concurrentCount() {
        return 5;
    }
}
